﻿#ifndef CHATCLIENT_H
#define CHATCLIENT_H

#include <QTcpSocket>

class ChatClientPrivate;
class ChatClient : public QTcpSocket {
  Q_OBJECT
public:
  ChatClient(QObject *parent = nullptr);
  ~ChatClient();

  bool setSocketDescriptor(qintptr socketDescriptor,
                           SocketState state = ConnectedState,
                           OpenMode openMode = ReadWrite);

public:
  void start();
  void stop();

  void writeMsg(const QByteArray &msg);

private:
  void readMsg();

signals:
  void receiveMsg(const QByteArray &rawMsg);

private:
  QScopedPointer<ChatClientPrivate> clientPrivate;
};

#endif // CHATCLIENT_H
